package viroyal.com.base.activity.exam;

import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.suntiago.baseui.activity.base.AppDelegateBase;
import com.suntiago.baseui.utils.date.DateStyle;
import com.suntiago.baseui.utils.date.DateUtils;

import viroyal.com.base.R;
import viroyal.com.base.net.entity.Exam;


/**
 * @author chenjunwei
 * @desc
 * @date 2019/4/30
 */
public class ExamDelegate extends AppDelegateBase<ExamModel> {

  @Override
  public int getRootLayoutId() {
    return R.layout.activity_exam;
  }

  @Override
  public void initWidget() {
//    setView();
  }

  @Override
  public void viewBindModel(ExamModel data) {

  }

  /**
   * 更新考試信息
   *
   * @param exam
   */
  public void updateExamView(Exam exam) {
    ((TextView) get(R.id.tv_exam_name)).setText(exam.name);
    ((TextView) get(R.id.tv_testingcenters)).setText(exam.testingcenters);
    ((TextView) get(R.id.tv_room)).setText(exam.room);
    String time = DateUtils.formatSecondTimestamp(exam.starttime / 1000, DateStyle.HH_MM) + "-" +
            DateUtils.formatSecondTimestamp(exam.endtime / 1000, DateStyle.HH_MM);
    ((TextView) get(R.id.tv_time)).setText(getActivity().getString(R.string.exam_time, time));
    ((TextView) get(R.id.tv_info)).setText(exam.info);
    ((SimpleDraweeView) this.get(R.id.background_img)).setImageURI(exam.url);
  }
}
